﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem.Controls
{
    public partial class MenuLeftGroupProduct : System.Web.UI.UserControl
    {
        public int catID;
        public int  parent_id;
        public int type;
        public string nameCat;
        protected void Page_Load(object sender, EventArgs e)
        {
              if (!Page.IsPostBack)
            {
                  
                  if (Request.QueryString["catID"] != null)
                      catID  = Convert.ToInt32( Request.QueryString["catID"].ToString());
                  else
                      Response.Redirect("Error.aspx");

                  
                  // Tu catID lay ve parent_ID ( cha cuoi cung ) tu procedure ( ket noi CSDL 1 lan )

                parent_id =
                    Convert.ToInt32(
                        DAL.DCollector.DBCollector.Instance.StoredProcedureGetTableByID("tbl_Category", catID,
                                                                                        "selectroot").Rows[0]["idroot"].ToString());


                 ltr_menugroup.Text = BOL.CategoryManager.Instance.getMenuCategory("tbl_Category",parent_id);

                 nameCat = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectWhereByID("tbl_Category", "*", "Category_ID1", parent_id, "selectwhereid").Rows[0]["Category_Name"].ToString();
             }
        }
    }
}